package com.xbongbong.saas.domain.dao;

import com.xbongbong.saas.domain.entity.ProductSerialBalanceEntity;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 序列号结存操作
 *
 * @author jiantao.xiong
 * @since 2020-05-18 11:23:17
 */
public interface ProductSerialBalanceDao {

    /**
     * 查询流水结存
     *
     * @param param 参数
     * @return 结存
     */
    List<ProductSerialBalanceEntity> findEntitys(@Param("param") Map<String, Object> param);

    /**
     * 数量查询
     *
     * @param param 参数
     * @return 数量
     */
    Integer getEntitysCount(@Param("param") Map<String, Object> param);

    /**
     * 新增数据
     *
     * @param tbSaasProductSerialBalance 实例对象
     * @return 影响行数
     */
    int insert(ProductSerialBalanceEntity tbSaasProductSerialBalance);

    /**
     * 修改数据
     *
     * @param tbSaasProductSerialBalance 实例对象
     * @return 影响行数
     */
    int update(ProductSerialBalanceEntity tbSaasProductSerialBalance);

    void insertBatch(@Param("list") List<ProductSerialBalanceEntity> productSerialBalanceList);

    Integer updateBatch(@Param("list") List<ProductSerialBalanceEntity> entitys, @Param("corpid") String corpid);

    /**
     * 批量删除
     *
     * @param refIdIn      关联单据id
     * @param corpid       公司id
     * @param businessType
     * @param enableSerialProductIds
     * @return 删除记录数
     */
    Integer deleteBatch(@Param("refIdIn") List<Long> refIdIn, @Param("corpid") String corpid, @Param("businessType") Integer businessType, @Param("productIdIn") List<Long> enableSerialProductIds);

    List<ProductSerialBalanceEntity> getByRefProductId(@Param("refProductId") Long refProductId, @Param("businessType") int businessType, @Param("corpid") String corpid);

    void deleteByRefId(@Param("refId") Long refId, @Param("businessType") Integer businessType, @Param("corpid") String corpid);

    ProductSerialBalanceEntity getByKey(@Param("key") Long key, @Param("corpid") String corpid);

    List<ProductSerialBalanceEntity> getBalanceByRefIdAndBusiness(@Param("refIdIn") List<Long> refIdIn, @Param("corpid") String corpid, @Param("businessType") Integer businessType);

    List<ProductSerialBalanceEntity> getBySeqKeyList(@Param("seqKeyIn") List<String> seqKeyList, @Param("corpid") String corpid);

    void updateBatchByParentId(@Param("corpid")String corpid, @Param("parentId")Long parentId, @Param("visible")Integer visible);
    /**
     * 根据关联产品id和业务类型删除
     * @param refIdIn
     * @param corpid
     * @param businessType
     * @param refProductIds
     * @return java.lang.Integer
     * @author 吴峰
     * @date 2022/3/29 10:15
     */
    Integer deleteBatchByRefProductId(@Param("refIdIn") List<Long> refIdIn, @Param("corpid")String corpid, @Param("businessType")Integer businessType, @Param("refProductIdIn") List<Long> refProductIds);
}
